package hotel.menu.activity;

import hotel.menu.untils.ActivityUntil;
import hotel.menu.untils.ConstantID;
import hotel.menu.untils.SharedPreferencesUntil;
import hotel.menu.untils.UpdateManager;

import com.example.youknow.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

public class Setting extends Activity implements OnClickListener {
	private ImageView back;
	private TextView update, about, word, welcome;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.setting);
		findID();
	}

	private void findID() {
		back = (ImageView) this.findViewById(R.id.setting_back);
		update = (TextView) this.findViewById(R.id.setting_update);
		about = (TextView) this.findViewById(R.id.setting_about);
		word = (TextView) this.findViewById(R.id.setting_leave_word);
		welcome = (TextView) this.findViewById(R.id.setting_welcome);
		back.setOnClickListener(this);
		update.setOnClickListener(this);
		word.setOnClickListener(this);
		welcome.setOnClickListener(this);
		about.setOnClickListener(this);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == 4) {
			ActivityUntil.back(Setting.this);
		}
		return super.onKeyDown(keyCode, event);
	}

	@Override
	public void onClick(View v) {
		if (v == update) {
			UpdateManager mUpdateManager = new UpdateManager(Setting.this);
			mUpdateManager.checkUpdateInfo();
		} else if (v == about) {
			ActivityUntil.next(Setting.this, About.class, null);
		} else if (v == word) {

			if (ConstantID.ISLOGIN) {
				ActivityUntil.next(Setting.this, LeaveWord.class, null);
			} else {
				ActivityUntil.next(Setting.this, Login.class, null);
			}

		} else if (v == welcome) {
			ActivityUntil.next(Setting.this, Guide.class, null);

		} else if (v == back) {
			ActivityUntil.back(Setting.this);
		}

	}

}
